package com.bleeth.fx.view.demo1;

import com.bleeth.fx.helper.ControlsHelper;
import com.bleeth.fx.layout.FormBuilder;
import com.bleeth.fx.layout.GirdCell;
import com.bleeth.fx.meta.IForm;
import com.bleeth.fx.meta.View;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.geometry.Pos;
import javafx.scene.control.TextField;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;

/**
 * @author Sakura
 * @version 1.0
 * @date 2021-11-13 22:17
 **/
@View("item_config")
public class ItemConfigView implements IForm {

    private StringProperty userProperty = new SimpleStringProperty();

    private StringProperty passwordProperty = new SimpleStringProperty();

    @Override
    public Region make(Property... properties) {
        userProperty.bindBidirectional(properties[0]);
        passwordProperty.bindBidirectional(properties[1]);

        TextField username = ControlsHelper.createTextField("", "用户名", "", "h5");
        TextField password = ControlsHelper.createPasswordField("");
        username.textProperty().bindBidirectional(userProperty);
        password.textProperty().bindBidirectional(passwordProperty);

        VBox loginForm = FormBuilder.form(400D, 400D)
                .addEmptyRow(10D)
                .addRow(GirdCell.createCell(1, Pos.CENTER), GirdCell.createCell(8, Pos.CENTER_LEFT), GirdCell.createCell(1, Pos.CENTER))
                .addCell(1, ControlsHelper.createLabel("登录", "", "h3"))
                .endRow(false)
                .addEmptyRow(20D)
                .addRow(GirdCell.createCell(1, Pos.CENTER), GirdCell.createCell(8, Pos.CENTER_LEFT), GirdCell.createCell(1, Pos.CENTER))
                .addCell(1, ControlsHelper.createLabel("你若不离不弃，我必生死相依", "", "h5"))
                .endRow(false)
                .addEmptyRow(20D)
                .addRow(GirdCell.createCell(1, Pos.CENTER), GirdCell.createCell(8, Pos.CENTER_LEFT), GirdCell.createCell(1, Pos.CENTER))
                .coverCell(1, username)
                .endRow(false)
                .addEmptyRow(20D)
                .addRow(GirdCell.createCell(1, Pos.CENTER), GirdCell.createCell(8, Pos.CENTER_LEFT), GirdCell.createCell(1, Pos.CENTER))
                .coverCell(1, password)
                .endRow(false)
                .addEmptyRow(20D)
                .addRow(GirdCell.createCell(1, Pos.CENTER), GirdCell.createCell(3, Pos.CENTER_LEFT), GirdCell.createCell(1, Pos.CENTER),
                        GirdCell.createCell(4, Pos.CENTER_RIGHT), GirdCell.createCell(1, Pos.CENTER))
                .addCell(1, ControlsHelper.createTextField("", "", "", "h5"))
                .addCell(3, ControlsHelper.createWrapperImg("flowers.png", 40, 135))
                .endRow(false)
                .addEmptyRow(20D)
                .addRow(GirdCell.createCell(1, Pos.CENTER), GirdCell.createCell(4, Pos.CENTER_LEFT), GirdCell.createCell(4, Pos.CENTER_LEFT),
                        GirdCell.createCell(1, Pos.CENTER))
                .addCell(1, ControlsHelper.createCheckBox("记住我"))
                .endRow(false)
                .addEmptyRow(20D)
                .addRow(GirdCell.createCell(1, Pos.CENTER), GirdCell.createCell(8, Pos.CENTER), GirdCell.createCell(1, Pos.CENTER))
                .coverCell(1, ControlsHelper.createBtn("登录", "btn-info", "h5"))
                .endRow(false)
                .build();
        return loginForm;
    }


    @Override
    public void css() {
        //css加载
    }


}
